package concurrent.pool;

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
 * @author Jay
 */
public class ThreadPoolExecutor {
    private final int corePoolSize;
    private final int maximumPoolSize;

    private final long keepAliveTime;
    private final TimeUnit timeUnit;

    private final BlockingQueue<Runnable> taskQueue;
    private final Set<Worker> workers;

    private final RejectPolicy<Runnable> rejectPolicy;

    public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit timeUnit, RejectPolicy<Runnable> rejectPolicy) {
        if(corePoolSize <= 0 || maximumPoolSize <= 0 || corePoolSize > maximumPoolSize || keepAliveTime < 0){
            throw new IllegalArgumentException();
        }
        this.corePoolSize = corePoolSize;
        this.maximumPoolSize = maximumPoolSize;
        this.keepAliveTime = keepAliveTime;
        this.timeUnit = timeUnit;
        this.rejectPolicy = rejectPolicy;
        this.taskQueue = new BlockingQueue<>();
        this.workers = new HashSet<>(maximumPoolSize);
    }

    class Worker extends Thread{
        private Runnable task;

        public Worker(Runnable task) {
            this.task = task;
        }

        @Override
        public void run() {

        }
    }
}
